<?php

class Hospital_model extends CI_Model {
    

    function getInfoHospital($coUsuario) {
      $this->db->select('hosp.*,
                         estado.nombre AS nb_estado');
      $this->db->from('configuracion_hospital AS hosp');
      $this->db->join('configuracion_estado AS estado','estado.id = hosp.estado_id');
      $this->db->where('hosp.usuario_id',$coUsuario);
      
      $query = $this->db->get();
      
      if($query->num_rows() > 0):
        return $query->row();    
      endif;
    }
    
    function registrarEncuesta($coHospital,$fechaRegistro,$horaRegistro,$semanaRegistro,$anioRegistro) 
    {
      $data = array(
        'hospital_id' => $coHospital,
        'fechacarga'  => $fechaRegistro,
        'horacarga'   => $horaRegistro,
        'numeroSem'   => $semanaRegistro,
        'anio'        => $anioRegistro,
        'inter_quirur_urgentes' => $this->input->post('iq_urgentes'), 
        'inter_quirur_electiva' =>  $this->input->post('iq_electivas'), 
        'pac_hosp_adultos' =>  $this->input->post(''),
        'pac_hosp_ninos' =>  $this->input->post(''),
        'pac_vistos_emer_adultos' =>  $this->input->post(''),
        '' =>  $this->input->post(''),
        '' =>  $this->input->post(''),
        '' =>  $this->input->post(''),
        '' =>  $this->input->post(''),
      );
      
      $this->db->insert('historico_histmov',$data);
    }
}